package com.mingqijia.gassafety.statistics.controller;

import com.gap.basic.base.CommonResponse;
import com.mingqijia.gassafety.db.entity.vo.PlatformBrandDetailResp;
import com.mingqijia.gassafety.db.entity.vo.PlatformEquipmentResp;
import com.mingqijia.gassafety.shared.utils.commonUtils.PageUtil;
import com.mingqijia.gassafety.statistics.request.ScreenCompanyManageReq;
import com.mingqijia.gassafety.statistics.request.ScreenStatisticsAreaReq;
import com.mingqijia.gassafety.statistics.request.ScreenStatisticsMOrGReq;
import com.mingqijia.gassafety.statistics.request.ScreenStatisticsReq;
import com.mingqijia.gassafety.statistics.response.*;
import com.mingqijia.gassafety.statistics.service.ScreenStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@Api(tags = "业务-大屏统计（新）")
@RequestMapping("/screen/statistics/data")
@Slf4j
public class ScreenStatisticsController {

    @Autowired
    private ScreenStatisticsService screenStatisticsService;

    @PostMapping("/platform/apply/situation")
    @ApiOperation(value = "平台应用情况")
    public CommonResponse<PlatformApplySituationResponse> platformApply(@RequestBody(required = false) ScreenStatisticsReq req){
        return CommonResponse.success(screenStatisticsService.platformApply(req));
    }

    @PostMapping("/platform/apply/list")
    @ApiOperation(value = "区域-地图数据列表")
    public CommonResponse<List<PlatformApplyListResponse>> platformApplyList(){
        return CommonResponse.success(screenStatisticsService.platformApplyList());
    }

    @PostMapping("/platform/area/list")
    @ApiOperation(value = "集团-集团查询区域地图数据列表")
    public CommonResponse<List<PlatformApplyListResponse>> platformAreaList(){
        return CommonResponse.success(screenStatisticsService.platformAreaList());
    }

    @PostMapping("/platform/popup")
    @ApiOperation(value = "区域-弹出层")
    public CommonResponse<PlatformPopupResponse> platformPopop(@RequestBody(required = false) ScreenStatisticsReq req){
        return CommonResponse.success(screenStatisticsService.platformPopop(req));
    }

    @PostMapping("/platform/area/popup")
    @ApiOperation(value = "集团-集团区域弹出层")
    public CommonResponse<PlatformPopupResponse> platformAreaPopop(@RequestBody(required = false) ScreenStatisticsAreaReq req){
        return CommonResponse.success(screenStatisticsService.platformAreaPopop(req));
    }

    @PostMapping("/platform/brand")
    @ApiOperation(value = "平台品牌厂家")
    public CommonResponse<List<PlatformBrandDetailResp>> platformBrand( @RequestBody(required = false) ScreenStatisticsReq req){
        return CommonResponse.success(screenStatisticsService.platformBrand(req));
    }

    @PostMapping("/group/platform/brand")
    @ApiOperation(value = "集团-集团平台品牌厂家")
    public CommonResponse<List<PlatformBrandDetailResp>> groupPlatformBrand(){
        return CommonResponse.success(screenStatisticsService.groupPlatformBrand());
    }

    @PostMapping("/platform/equipment")
    @ApiOperation(value = "平台设备品类")
    public CommonResponse<List<PlatformEquipmentResp>> platformEquipment(@RequestBody(required = false) ScreenStatisticsReq req){
        return CommonResponse.success(screenStatisticsService.platformEquipment(req));
    }

    @PostMapping("/platform/alarm/data")
    @ApiOperation(value = "报警器+智慧厨房前5条告警数据")
    public CommonResponse<List<PlatformAlarmDataResp>> platformAlarmData(@RequestBody(required = false) ScreenStatisticsReq req){
        return CommonResponse.success(screenStatisticsService.platformAlarmData(req));
    }

    @PostMapping("/platform/alarm/situation")
    @ApiOperation(value = "集团-报警情况")
    public CommonResponse<AlarmSituationResp> platformAlarmSituation(){
        return CommonResponse.success(screenStatisticsService.platformAlarmSituation());
    }

    @PostMapping("/area/alarm/situation")
    @ApiOperation(value = "区域-区域截止2024年发生的报警情况")
    public CommonResponse<PlatformAlarmSituationResp> areaAlarmSituation(){
        return CommonResponse.success(screenStatisticsService.areaAlarmSituation());
    }

    @PostMapping("/arae/alarm/device/month")
    @ApiOperation(value = "集团-各区域报警设备情况每月的饼图")
    public CommonResponse<AraeAlarmDeviceMonthResp> araeAlarmDeviceMonth(@RequestBody(required = false) ScreenStatisticsMOrGReq req){
        return CommonResponse.success(screenStatisticsService.araeAlarmDeviceMonth(req));
    }

    @PostMapping("/company/alarm/device/pie")
    @ApiOperation(value = "区域-各企业报警设备情况每月的饼图")
    public CommonResponse<CompanyAlarmDeviceResp> companyAlarmDevicePie(){
        return CommonResponse.success(screenStatisticsService.companyAlarmDevicePie());
    }

    @PostMapping("/arae/alarm/device/day")
    @ApiOperation(value = "集团-各区域报警设备情况每天的柱状图")
    public CommonResponse<AraeAlarmDeviceDayResp> araeAlarmDeviceDay(){
        return CommonResponse.success(screenStatisticsService.araeAlarmDeviceDay());
    }

    @PostMapping("/company/alarm/device/histogram")
    @ApiOperation(value = "区域-各企业报警设备情况每天的柱状图")
    public CommonResponse<CompanyAlarmDeviceHistogramResp> companyAlarmDeviceHistogram(){
        return CommonResponse.success(screenStatisticsService.companyAlarmDeviceHistogram());
    }

    @PostMapping("/arae/alarm/dispose")
    @ApiOperation(value = "集团-本月告警处理情况")
    public CommonResponse<List<AraeAlarmDisposeResp>> araeAlarmDispose(){
        return CommonResponse.success(screenStatisticsService.araeAlarmDispose());
    }

    @PostMapping("/company/alarm/dispose")
    @ApiOperation(value = "区域-企业本月告警处理情况")
    public CommonResponse<List<CompanyAlarmDisposeResp>> companyAlarmDispose(){
        return CommonResponse.success(screenStatisticsService.companyAlarmDispose());
    }

    @PostMapping("/arae/state")
    @ApiOperation(value = "集团-区域状态")
    public CommonResponse<List<AraeStateResp>> araeState(){
        return CommonResponse.success(screenStatisticsService.araeState());
    }

    @PostMapping("/company/state")
    @ApiOperation(value = "区域-企业状态")
    public CommonResponse<List<CompanyStateResp>> companyState(){
        return CommonResponse.success(screenStatisticsService.companyState());
    }

    @PostMapping("/company/manage")
    @ApiOperation(value = "企业管理")
    public CommonResponse<PageUtil<PlatformCompanyManageResp>> companyManage(@RequestBody(required = false) ScreenCompanyManageReq req){
        return CommonResponse.success(screenStatisticsService.companyManage(req));
    }

    @PostMapping("/device/spread")
    @ApiOperation(value = "设备推广前5企业")
    public CommonResponse<DeviceSpreadResp> deviceSpread( @RequestBody(required = false) ScreenStatisticsReq req) {
        return CommonResponse.success(screenStatisticsService.deviceSpread(req));
    }

    @PostMapping("/device/broken/data")
    @ApiOperation(value = "设备故障统计接口")
    public CommonResponse<DeviceBrokenDataResp> deviceBrokenData( @RequestBody(required = false) ScreenStatisticsReq req) {
        return CommonResponse.success(screenStatisticsService.deviceBrokenData(req));
    }

    @PostMapping("/broken/device/situation")
    @ApiOperation(value = "集团-故障设备情况")
    public CommonResponse<BrokenDeviceSituationResp> brokenDeviceSituation(){
        return CommonResponse.success(screenStatisticsService.brokenDeviceSituation());
    }
}
